package beautiful.butterfly.drds.binlog.parser;


import beautiful.butterfly.drds.binlog.connection.ConnectionAttributes;
import beautiful.butterfly.drds.binlog.event.EventData;
import beautiful.butterfly.drds.binlog.event.data.XidEventData;
import beautiful.butterfly.drds.binlog.netty.server.NioSocketChannelExtend;
import beautiful.butterfly.drds.binlog.utils.ByteUtils;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

public class XidEventDataParser implements EventDataParser
{// 提交数据


    @Override
    public EventData parse(ByteBuf msg, ChannelHandlerContext context, int checksumLength)
    {
        // LoggerUtils.debug(logger, "");
        long xid = ByteUtils.readUnsignedLong(msg, 8);
        XidEventData xidEventData = new XidEventData();
        xidEventData.setXid(xid);
        // 删除保留的tableMapData
        ConnectionAttributes connectionAttributes = ((NioSocketChannelExtend) context.channel()).getConnectionAttributes();
        if (null != connectionAttributes)
        {
            connectionAttributes.deleteTableMapEventData();
        }
        return xidEventData;
    }

}
